<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改数据集')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-xRepDataset-edit" th:object="${xRepDataset}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">
			<div class="form-group">	
				<label class="col-sm-3 control-label">数据集名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" th:field="*{name}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">sql：</label>
				<div class="col-sm-8">
					<input id="sqlContext" name="sqlContext" th:field="*{sqlContext}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">引用数据源id：</label>
				<div class="col-sm-8">
					<div class="col-sm-8" style="margin:0 0;">
						<select class="col-sm-8" id="dsId" name="dsId" th:field="*{dsId}" th:value="*{dsId}">
						</select>
					</div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
                         <input type="checkbox" th:checked="*{state}==0?true:false" class="onoffswitch-checkbox" id="state">
                         <label class="onoffswitch-label" for="state">
                             <span class="onoffswitch-inner"></span>
                             <span class="onoffswitch-switch"></span>
                         </label>
                     </div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注信息：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" th:field="*{remark}" class="form-control" type="text">
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "system/xRepDataset";
		$("#form-xRepDataset-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-xRepDataset-edit').serialize());
	        }
	    }
		$(document).ready(function(){
			$.ajax({
				url:"/system/extDatasource/list",
				type:"post",
				success:function(res){
					var selectId=[[${xRepDataset.dsId}]]
					for (var i in res.rows) {
						if(res.rows[i].id==selectId){
							$("#dsId").append("<option selected value='" + res.rows[i].id + "'>" + res.rows[i].dsName +" </option>")
						}else{
							$("#dsId").append("<option value='" + res.rows[i].id + "'>" + res.rows[i].dsName +" </option>")
						}
					}
				}
			})
		})
	</script>
</body>
</html>
